//
// transreg.h
// libprotea
// Tools Library for the Protea Project / Business Transaction Registration
// Copyright (C) 2003, 2004, 2005 eXegeSys, Inc.
// Copyright (C) 2008 Bruce A. James
//
// This program is part of the Protea Project.
//
// The Protea Project is free software; you can redistribute it and/or modify it 
// under the terms of the GNU General Public License as published by the 
// Free Software Foundation, either version 3 of the License, or (at your 
// option) any later version.
//
// The Protea Project is distributed in the hope that it will be useful, but 
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
// for more details.
// 
// You should have received a copy of the GNU General Public License along 
// with this program.  If not, see <http://www.gnu.org/licenses/>.
// 
// Please send correspondence to:
// 
// theproteaproject@gmail.com
//

#ifndef __PROTEA_TRANSREG_H__
#define __PROTEA_TRANSREG_H__

// Forward declarations
class XCSharedLibrary;
class XCTransactionInfo;

// Type defs
typedef XCTransactionInfo* (*trans_func_type)( XCTransactionInfo* );

struct __EXPORT XCTransRegLibrary {
	char* description;
	XCSharedLibrary* module;
	XCTransRegLibrary* next;
};


struct __EXPORT XCTransRegTransaction {
	long trans_number;
	trans_func_type transaction_code;
	long calls;

	XCTransRegLibrary containing_library;

	XCTransRegTransaction* next;
};


class __EXPORT XCTransRegServer {
public:
	XCTransRegServer();
	~XCTransRegServer();

	bool RegisterLibrary( const char* name, XCSharedLibrary* library );
	bool RegisterTransaction( long trans_number, trans_func_type trans_code );

	XCTransRegTransaction* FindTransaction( long trans_number );

	void OutputHashTable();

	int transaction_count;

private:
	XCTransRegTransaction** Hash;
	XCTransRegLibrary* Libraries;
};

#endif

